<template>
  <div class="card">
    <div class="card-header">群组公告</div>
    <div class="card-content easy-container">
      <router-link
        v-if="annc.title"
        :to="`/groups/${groupId}/announcements`"
        class="title easy-container-min"
        v-text="annc.title"
      />
      <div v-else class="easy-container-min text-center info">当前群组没有公告</div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'annc', // 群组公告
  data() {
    return {
      annc: {},
    };
  },
  computed: {
    groupId() { return this.$route.params.groupId; },
  },
  created() { this.loadAnnouncements(); },
  methods: {
    loadAnnouncements() {
      this.$api.groupAnnouncements.index({
        groupId: this.groupId,
        number: 1,
        page: 1,
      }).then((res) => {
        this.annc = res.data[0] || {};
      }).catch(() => {});
    },
  },
};
</script>

<style></style>
